package com.tj.jinzao.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tj.jinzao.R;

import java.util.List;

public class StartLiveMessageAdapter extends Base_Adapter {
    public StartLiveMessageAdapter(Context context, List list, boolean isFirst) {
        super(context, list, isFirst);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.item_message_live,null);
            viewHolder.content=convertView.findViewById(R.id.content);
            viewHolder.nickName=convertView.findViewById(R.id.nickName);
            viewHolder.content_lay=convertView.findViewById(R.id.content_lay);
            convertView.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        if(position%2==0){
            viewHolder.content.setText("尽早李老师驾到");
            viewHolder.nickName.setVisibility(View.GONE);
            viewHolder.content.setTextColor(context.getResources().getColor(R.color.white));
            viewHolder.content_lay.setBackgroundResource(R.drawable.live_message_blue);
        }else {
            viewHolder.nickName.setText("李老师：");
            viewHolder.nickName.setVisibility(View.VISIBLE);
            viewHolder.content.setText("你们好厉害啊");
            viewHolder.content.setTextColor(context.getResources().getColor(R.color.global_bg));
            viewHolder.content_lay.setBackgroundResource(R.drawable.live_message_white);

        }

        return convertView;
    }
    class ViewHolder{
        TextView content,nickName;
        LinearLayout content_lay;

    }
}
